//
//  FZHomeBaseCollectionViewCell.m
//  EnglishTalk
//
//  Created by CyonLeuPro on 15/6/25.
//  Copyright (c) 2015年 Feizhu Tech. All rights reserved.
//

#import "FZHomeBaseCollectionViewCell.h"
#import "UIImageView+FZDefaultPlaceholder.h"

@interface FZHomeBaseCollectionViewCell ()
@property (strong, nonatomic) CALayer *coverHighlightLayer;
@end

@implementation FZHomeBaseCollectionViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    FZStyleSheet *css = [FZStyleSheet currentStyleSheet];
    self.iconImageView.clipsToBounds = YES;
    self.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
    
    self.titleLabel.font = css.fontOfH3;
    self.titleLabel.textColor = css.color_3;
    self.titleLabel.numberOfLines = 1;
    self.titleLabel.lineBreakMode = NSLineBreakByWordWrapping | NSLineBreakByTruncatingTail;
    self.subtitleLabel.textColor = css.color_5;
    self.subtitleLabel.font = css.fontOfH5;
    self.numLabel.textColor = [UIColor whiteColor];
    self.numLabel.font = css.fontOfH4;
}


- (void)updateCellInfo:(id)data {
//    [self.iconImageView fz_setImageWithDefaultPlaceholderWithURL:nil placeholderSize:self.iconImageView.bounds.size completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
//        
//    }];
    //self.tipIconImageView.image = [UIImage imageNamed:@"mainPageMaiIcon.png"];
}


- (NSString *)displayStringForNumber:(long long)number {
    if (number <= 10000) {
        return [NSString stringWithFormat:@"%ld", (long)number];
    } else if (number < 10000 * 10000) {
        return [NSString stringWithFormat:@"%.2f万", (float)number / 10000.f];
    } else {
        return [NSString stringWithFormat:@"%.2f亿", (double)number / (10000 * 10000) ];
    }
}

#pragma  mark - Override method

//- (void)setSelected:(BOOL)selected {
//    [super setSelected:selected];
//}

- (void)setHighlighted:(BOOL)highlighted {
    [super setHighlighted:highlighted];
    
    [self addHightlightLayer:highlighted];
}

- (void)addHightlightLayer:(BOOL)add {
    if (!self.coverHighlightLayer) {
        self.coverHighlightLayer = [[CALayer alloc] init];
        self.coverHighlightLayer.hidden = YES;
        [self.contentView.layer addSublayer:self.coverHighlightLayer];
    }
    self.coverHighlightLayer.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4].CGColor;
    self.coverHighlightLayer.hidden = !add;
    self.coverHighlightLayer.frame = self.iconImageView.bounds;
}


@end
